package com.cn.zpark;

import com.cn.zpark.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.Statement;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: JdbcDelete
 * @Description:删除数据
 * @author: RZS
 * @date: 2022/3/30  20:06
 */
public class JdbcDelete {
    public static void main(String[] args) {
        // 准备连接信息
        Connection conn = null;
        Statement stat = null;

        try {
            // 获取连接对象
            conn = JDBCUtils.getConn();
            // 编写sql
            String sql = "delete from tab1 where id=1";
            // 创建statement对象
            stat = conn.createStatement();
            // 执行sql
            int row = stat.executeUpdate(sql);
            System.out.println("删除成功: " + row);

        } catch(Exception e) {
            e.printStackTrace();
        } finally {
            // 关闭资源
            JDBCUtils.close(conn, stat);
        }
    }
}
